package process_control;

public class ForLoopDemo {
    public static void main(String[] args) {
        // 水仙花数，是一个三位数，且个位、十位、百位的立方和仍是该数本身
        //利用循环来求出100到999的水仙花数
        System.out.println("100到999的水仙花数：");
        for(int i = 100; i <= 999; i++){
            int gewei = i % 10;
            int shiwei = i / 10 % 10;
            int baiwei = i / 100;
            int lifanghe = gewei * gewei * gewei + shiwei * shiwei * shiwei + baiwei * baiwei + baiwei;
            if(lifanghe == i){
                System.out.println(i);
            }
        }
    }
}
